package com.qian.fmall.controller;



import com.qian.fmall.cart.service.CartInterface;
import com.qian.fmall.commons.ResultSet;
import com.qian.fmall.pojo.ShoppingCart;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/cart")
@CrossOrigin
public class CarController {
    @DubboReference
    private CartInterface cartInterface;
    @RequestMapping("add")
    public ResultSet checkLogin(ShoppingCart shoppingCart)
    {
        shoppingCart.setCartTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        System.out.println(shoppingCart);
        return cartInterface.addShoppingCart(shoppingCart);
    }
    @RequestMapping("query")
    public ResultSet query(String userId)
    {
       return cartInterface.showShoppingCart(userId);
    }
    @RequestMapping("cartList")
    public ResultSet getCartInfoByCartIds(String cartIds)
    {
        System.out.println(cartIds);
        return cartInterface.getShoppingCartSByCartIds(cartIds);
    }
}
